Rockchip: Add some debug assertions in the PMU driver
authorSandrine Bailleux <[email protected]>
Thu, 5 May 2016 09:04:15 +0000 (10:04 +0100)
committerSandrine Bailleux <[email protected]>
Thu, 5 May 2016 14:35:46 +0000 (15:35 +0100)
This patch adds some debug assertions ensuring that array indices
are within the bounds of the array.

Change-Id: I96ee81d14834c1e92cdfb7e60b49995cdacfd93a

plat/rockchip/rk3368/drivers/pmu/pmu.c
plat/rockchip/rk3399/drivers/pmu/pmu.c

index 50e2bf87c85c6c771489e432913118f9862e832f..53d333b3d3c708a6cae9db89cb084380aba22e94 100644 (file)
@@ -349,6 +349,7 @@ static int cores_pwr_domain_on(unsigned long mpidr, uint64_t entrypoint)
        cpus_id_power_domain(cluster, cpu, pmu_pd_off, CKECK_WFEI_MSK);
 
        cpuon_id = (cluster * PLATFORM_CLUSTER0_CORE_COUNT) + cpu;
+       assert(cpuon_id < PLATFORM_CORE_COUNT);
        assert(cpuson_flags[cpuon_id] == 0);
        cpuson_flags[cpuon_id] = PMU_CPU_HOTPLUG;
        cpuson_entry_point[cpuon_id] = entrypoint;
index 1493a4dd8acc2f98df30886f6781352d1d93a216..859e89f5ca330dcb59de31212bd6b8c0c1182aa7 100644 (file)
@@ -132,11 +132,13 @@ void plat_rockchip_pmusram_prepare(void)
 
 static inline uint32_t get_cpus_pwr_domain_cfg_info(uint32_t cpu_id)
 {
+       assert(cpu_id < PLATFORM_CORE_COUNT);
        return core_pm_cfg_info[cpu_id];
 }
 
 static inline void set_cpus_pwr_domain_cfg_info(uint32_t cpu_id, uint32_t value)
 {
+       assert(cpu_id < PLATFORM_CORE_COUNT);
        core_pm_cfg_info[cpu_id] = value;
 #if !USE_COHERENT_MEM
        flush_dcache_range((uintptr_t)&core_pm_cfg_info[cpu_id],
@@ -234,6 +236,7 @@ static int cores_pwr_domain_on(unsigned long mpidr, uint64_t entrypoint)
 {
        uint32_t cpu_id = plat_core_pos_by_mpidr(mpidr);
 
+       assert(cpu_id < PLATFORM_CORE_COUNT);
        assert(cpuson_flags[cpu_id] == 0);
        cpuson_flags[cpu_id] = PMU_CPU_HOTPLUG;
        cpuson_entry_point[cpu_id] = entrypoint;
@@ -257,6 +260,7 @@ static int cores_pwr_domain_suspend(void)
 {
        uint32_t cpu_id = plat_my_core_pos();
 
+       assert(cpu_id < PLATFORM_CORE_COUNT);
        assert(cpuson_flags[cpu_id] == 0);
        cpuson_flags[cpu_id] = PMU_CPU_AUTO_PWRDN;
        cpuson_entry_point[cpu_id] = (uintptr_t)psci_entrypoint;